package com.hewanning.toy.play.controller;

import com.hewanning.toy.play.model.dto.LoginDto;
import com.hewanning.toy.play.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * 授权接口
 *
 * @author robin_he
 * @date 2020/1/3
 */
@RestController
@RequestMapping(value = "/auth")
public class AuthController {

    @Autowired
    private UserService userService;

    @PostMapping("/login")
    public Object login(@RequestBody @Valid LoginDto loginDto) {
        Object result = userService.login(loginDto);
        return result;
    }

    @DeleteMapping("/logout")
    public void logout(HttpServletRequest request) {
        userService.logout(request);
    }
}
